import * as Router from 'koa-router';
// import { IRouterContext } from '../core/IRouterContext';
import { IRouterContext } from 'koa-router';
import rkService from '../service/RkService';
const motorCtr: Router = require('koa-router')();
motorCtr.prefix('/api')
import loginUtil from './../core/LoginUtils';

/**
 * b2b
 * 入库
 * 采购配送单查询
 * pda扫描配送单 只生成配送单号 deliveryId :S012496
 * 采购配送单查询
 * 采购订单配送到货后扫描入库时，根据采购订单配送单号查询配送单详情
 */
motorCtr.post('/motor/getSupDeliveryInfo', async (ctx: IRouterContext, next: any) => {

    console.log('采购配送单查询__________________');
    let authorization :any = ctx.header.authorization;
    //console.log('authorization__________________',authorization);
    let rq: any = ctx.request
    let data = rq.body;
    let result = await rkService.getSupDeliveryInfo(data,authorization);

    ctx.status = 200;
    ctx.body = result;

    await next()
})


/**
 * b2b
 * //nc 查询 货位号 
 * 采购入库接口 
 * 参数 
 * ERP 采购订单号 :purchasebillcode   -----------平台采购订单号就是"originalOrderId": "CD1612280004",
 * 需求描述:库管员在PDA上扫描配送单，点击确认操作后，在NC系统上生成采购入库单。
 * 平台送货单号 : deliverybillcode
 * 单据明细: details  > List<Map>
 *      订单id : corderbid
 *      配送数量 :nnum     > number
 * 
 * {
    "purchasebillcode":"111",
    "deliverybillcode":"222",
    "details":{"corderbid":"12312","nnum":123}
    }
 */
motorCtr.post('/motor/acceptSupDelivery', async (ctx: IRouterContext, next: any) => {

   console.log('进入采购入库接口__________________');
   let authorization :any = ctx.header.authorization;
   let rq: any = ctx.request
   let data = rq.body;
   let result = await rkService.acceptSupDelivery(data,authorization);

   ctx.status = 200;
   ctx.body = result;

   await next()

})


export default motorCtr;